package com.gxlevi.db.bean

import com.alibaba.fastjson.JSON

case class Canal(
                  var emptyCount: Long,
                  var logFileName: String,
                  var dbName: String,
                  var logFileOffset: Long,
                  var eventType: String,
                  var columnValueList: String,
                  var tableName: String,
                  var timestamp: Long
                )

object Canal {
  def apply(json: String) = {
    JSON.parseObject(json, classOf[Canal])
  }

  def main(args: Array[String]): Unit = {
    val json = "{\"emptyCount\":2,\"logFileName\":\"mysql-bin.000002\",\"dbName\":\"pyg\",\"logFileOffset\":10459,\"eventType\":\"DELETE\",\"columnValueList\":[{\"columnName\":\"commodityId\",\"columnValue\":\"6\",\"isValid\":false},{\"columnName\":\"commodityName\",\"columnValue\":\"欧派\",\"isValid\":false},{\"columnName\":\"commodityTypeId\",\"columnValue\":\"3\",\"isValid\":false},{\"columnName\":\"originalPrice\",\"columnValue\":\"43000.0\",\"isValid\":false},{\"columnName\":\"activityPrice\",\"columnValue\":\"40000.0\",\"isValid\":false}],\"tableName\":\"commodity\",\"timestamp\":1588514589000}"
    val canal = Canal(json)
    println(canal)
  }
}
